const Koa = require('./index')
// const Koa = require('koa')
const app = new Koa();

app.use(async (ctx, next) => {
    if (ctx.req.url === '/favicon.ico') {
        ctx.res.status = 204; // 设置响应状态码为204，表示请求已成功处理但无需返回响应内容
        return;
    }
    next()
})

app.use(async (ctx, next) => {
    console.log('中间件1-开始')
    await next();
    console.log('中间件1-结束')
});

app.use(async (ctx, next) => {
    console.log('中间件2-开始')
    await next();
    console.log('中间件2-结束')
});

app.use(async (ctx, next) => {
    console.log('中间件3-开始')
    await next();
    console.log('中间件3-结束')
});

app.use(async (ctx, next) => {
    ctx.body = 'Hello, World!';
    await next();
});

app.listen(3002, () => {
    console.log('Server running on port 3002');
});
